<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ColumnGen
 *
 * @author vlad
 */
class ColumnGen extends DBGenerator {
    
    private $_column;
    private $_name;
    private $_phpCode;
    
    public function __construct(SQLColumn $struct) {
        if (!empty($struct)) {$this->_column = $struct;}
        return $this;
    }
    
    
    public function Generate() {
        $this->_phpCode = "";
        
        // print "Generating column ".$this->_column->_name."...\n";
        // foreach($this->_column->GetProperties() as $property => $value) {
        // }
            $name = "".$this->_column;
            $lcName = strtolower($name);
            $humanizedName = $this->HumanizeName($name);
            $this->_phpCode .= <<<EOF
    protected \$__$lcName;
    
    public function getInitial{$humanizedName}() {
        return \$__$lcName;
    }
    
    public function setInitial{$humanizedName}(\$value) {
        \$this->__$lcName = \$value;
    }
    
    public function getPropertyName_{$humanizedName}() {
        return "{$name}";
    }
    
    protected \$_$lcName;
    
    public function get{$humanizedName}() {
        return \$_$lcName;
    }
    
    public function set{$humanizedName}() {
        \$this->_$lcName = \$value;
    }
    
    public function reset{$humanizedName}() {
        \$this->_$lcName = \$this->__$lcName;
    }
EOF;
            //print "\t$property => $value\n";
        //print "done\n";
        return $this;
    }
    
    public function __toString() {
        return $this->_phpCode;
    }
}

?>
